package BiShi.first.wangyi;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main3 {
    public static void main(String[] args) {
        //System.out.println(helper(0,0));
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            int m = sc.nextInt();
            int f = sc.nextInt();
            Set<Integer> set = new HashSet<>();
            set.add(f);
            int[][] p = new int[m][];
            int nums;
            boolean flag = false;
            for(int i = 0 ; i < m ; i++){
                nums=  sc.nextInt();
                p[i] = new int[nums];
                flag = false;
                for(int j = 0 ; j < nums; j++){
                    p[i][j] = sc.nextInt();
                    if(set.contains(p[i][j])){
                        flag =  true;
                    };
                }
                if(flag){
                    for(int j = 0 ; j < nums; j++){
                        set.add(p[i][j]);
                    }
                }
            }
            System.out.println(set.size());
        }
    }

}